<?php
class odb{
	private static $odb = array();
	
	/**
	 * @return DB
	 */
	public static function db(){		
		if( ! is_object( self::$odb['db'])){
		 	include_once PATH_API . '/db/class.db.php';
		 	self::$odb['db'] = new DB(CoreFactory::$config['db_host'], CoreFactory::$config['db_user'], CoreFactory::$config['db_pass'], CoreFactory::$config['db_name']);
		}
		return self::$odb['db'];
	}
	
	/**
	 * 断开所有连接状态的数据库
	 */
	public static function close(){
		foreach ((array)self::$odb as $db){
			$db->close();
		}
	}
}